//Source file: D:\\test\\com\\ce\\pms\\custservice\\model\\BillDO.java

package com.ce.pms.custservice.model;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.ce.pms.common.model.SysInfo;
import com.ce.pms.common.model.SysrefcodeDO;
import com.sitechasia.webx.core.model.IDomainObject;

/**
 * 实体名称:帐单摘要 关联数据表:CE_CUST_SERVICE_BILL
 *
 * @author yandawei
 * @CreateDate:2008-12-8
 */
@Entity
@Table(name = "CE_CUST_SERVICE_BILL")
public class BillDO implements IDomainObject {

	/**
	 * 001新建
	 */
	public static final String BILL_STATUS_NEW_CODE="001";

	/**
	 * 002已传递
	 */
	public static final String BILL_STATUS_TRANSLATE_CODE="002";

	/**
	 * 帐单摘要_ID
	 */
	@Id
	@GeneratedValue
	@Column(name = "CUST_SERVICE_BILL_ID")
	private Long keyword;

	/**
	 * 应收
	 */
	@Column(name = "DEBIT", precision = 18, scale = 2)
	private BigDecimal debit = new BigDecimal(0.00);

	/**
	 * 收到
	 */
	@Column(name = "CREDIT", precision = 18, scale = 2)
	private BigDecimal credit = new BigDecimal(0.00);

	/**
	 * 收费模式:001现场收费;002月末结算
	 */
	@Column(name = "MODE", nullable = false, length = 3)
	private String mode;

	/**
	 * 备注
	 */
	@Column(name = "REMARK", length = 100)
	private String remark;

	/**
	 * 抛帐到费用系统的物业账户的应收交易ID
	 */
	@Column(name = "TRANSACTION_ID")
	private Long transactionID;

	/**
	 * 费用状态:001新建;002已传递
	 */
	@Column(name = "STATUZ", nullable = false, length = 3)
	private String statuz;

	/**
	 * 派工单ID
	 */
	@OneToOne(fetch= FetchType.LAZY)
	@JoinColumn(name = "DISPATCH_FORM_ID")
	private DispatchFormDO theDispatchFormDO;

	/**
	 * 系统信息
	 */
	@Embedded
	private SysInfo sysInfo;

	/**
	 * 默认构造器
	 *
	 * @return com.ce.pms.custservice.model.BillDO
	 * @roseuid 49365F790109
	 */
	public BillDO() {
		initStatuz();
	}


	/**
	 * 自定义构造器
	 *
	 * @param mode -
	 *           收费模式
	 * @param statuz -
	 *            费用状态
	 * @param sysInfo -
	 *            系统信息
	 * @return com.ce.pms.custservice.model.BillDO
	 * @roseuid 4923E5F302CE
	 */
	public BillDO(String mode, String statuz, SysInfo sysInfo) {
		this.mode = mode;
		this.statuz = statuz;
		this.sysInfo = sysInfo;
		initStatuz();
	}

	/**
	 * 设置状态”新建" statuz=001
	 *
	 * @roseuid 49364F7F02FD
	 */
	private void initStatuz() {
		setStatuz(BILL_STATUS_NEW_CODE);
	}

	/**
	 * 设置状态”已传递" statuz=002
	 *
	 * @roseuid 49364F7F032C
	 */
	public void setStatuzHasDelivery() {
		setStatuz(BILL_STATUS_TRANSLATE_CODE);
	}

	/**
	 * 回写抛帐到费用系统物业账户的应收交易ID
	 *
	 * @param transID -
	 *            抛帐到费用系统物业账户的应收交易ID
	 * @return Void
	 * @roseuid 4935FF270167
	 */
	public void writeBackTransactionID(Long transID) {
		setTransactionID(transID);
	}

	/**
	 * 是否允许编辑 1. 当帐单状态statuz=001时,返回true,当statuz=002时返回false.
	 *
	 * @return Boolean
	 * @roseuid 492A6B0D0109
	 */
	public Boolean isAllowUpdate() {
		if(BILL_STATUS_NEW_CODE.equals(getStatuz()))
			return true;
		return false;
	}

	/**
	 * 更新应收金额
	 *
	 * @roseuid 49365DA6031C
	 * @param billNewDebit TODO
	 */
	public void updateReceivable(BigDecimal billNewDebit) {
		this.debit=billNewDebit;
	}

	public SysInfo getSysInfo() {
		return sysInfo;
	}

	public void setSysInfo(SysInfo sysInfo) {
		this.sysInfo = sysInfo;
	}

	/**
	 * @param debit
	 * @roseuid 49365E220157
	 */
	public void setDebit(BigDecimal debit) {

	}

	public BigDecimal getCredit() {
		return credit;
	}

	public void setCredit(BigDecimal credit) {
		this.credit = credit;
	}

	public Long getKeyword() {
		return keyword;
	}

	public void setKeyword(Long keyword) {
		this.keyword = keyword;
	}

	public String getMode() {
		return mode;
	}

	public void setMode(String mode) {
		this.mode = mode;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getStatuz() {
		return statuz;
	}

	public void setStatuz(String statuz) {
		this.statuz = statuz;
	}

	public DispatchFormDO getTheDispatchFormDO() {
		return theDispatchFormDO;
	}

	public void setTheDispatchFormDO(DispatchFormDO theDispatchFormDO) {
		this.theDispatchFormDO = theDispatchFormDO;
	}



	public Long getTransactionID() {
		return transactionID;
	}


	public void setTransactionID(Long transactionID) {
		this.transactionID = transactionID;
	}


	public BigDecimal getDebit() {
		return debit;
	}
	
	/**
	 * 功能描述: 是否是月末结算模式。 <br>
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-12-29  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public Boolean isMonthBalance(){
		return SysrefcodeDO.CE_CUST_SERVICE_BILL_MODE_ENDOFMONTH.equals(this.mode);
	}
}
